Ad2c converts X resource files into C declarations, appropriate for inclusion as fallback resources. The program is a sed(1) script which is effectively a finite state machine, escaping quotes and backslashes (and newlines where necessary), and adding quotes and commas as needed for array initialization.
It reads from the given files (or stdin if none are given) and writes the C declarations to stdout.
Foobar.ad.h: Foobar.ad ad2c Foobar.ad >Foobar.ad.h
The resulting C strings should be included (say in "foobar.c"):
static char fallback_resources[] = { #include "Foobar.ad.h" NULL };
This array of strings can then be given as a parameter to XtAppInitialize(3X) or otherwise used to initialize the application's resources. Running makedepend or adding the line
foobar.c: Foobar.ad.h
to the Makefile or Imakefile will ensure that "foobar.c" is recompiled when necessary (ie., whenever "Foobar.ad" changes).
This software is provided as is with no warranty expressed or implied. I hope you find it useful, but I won't be held responsable for any damage that may occur from reading, compiling, installing or using it.
You are free to use any part of this code for other purposes. It would be nice if you could keep my name on some part of whatever the final product is.
George Ferguson, ferguson@cs.rochester.edu.
Man page by Joseph Beckenbach, jerbil@ultra.com. Usage section added by George Ferguson. Example corrected by Tim Theisen, tim@cs.wisc.edu. Example further corrected by David Wojtowicz, davidw@vista.atmos.uiuc.edu.
Modified to work with Gnu and IBM sed by Charles Hannum, mycroft@gnu.ai.mit.edu.